using System;

namespace OpenRay
{
	public class FrameBuffer
	{
		private float[,,] buffer;
		
		public int Height {
			get;
			private set;
		}
		
		public int Width {
			get;
			private set;
		}
		
		public FrameBuffer ( int width, int height )
		{
			Height = height;
			Width = width;
			buffer = new float[height,width,4];
		}
		
		public void Resize( int width, int height )
		{	
			Height = height;
			Width = width;
			buffer = new float[height,width,4];
		}
		
		public void FillArgb( float[] c )
		{
			for ( uint i = 0; i < buffer.GetLength(1); i++ )
			{
				for ( uint j = 0; j < buffer.GetLength(0); j++ )
				{
					buffer[i,j,0] = c[0];
					buffer[i,j,1] = c[1];
					buffer[i,j,2] = c[2];
					buffer[i,j,3] = c[3];
				}
			}
		}
		
		public void SetPixelArgb( int x, int y, float[] c )
		{
			buffer[y,x,0] = c[0];
			buffer[y,x,1] = c[1];
			buffer[y,x,2] = c[2];
			buffer[y,x,3] = c[3];
		}
		
		public float[] GetArgb( int x, int y ) 
		{
			float[] ret = new float[4];
			
			ret[0] = buffer[y,x,0];
			ret[1] = buffer[y,x,1];
			ret[2] = buffer[y,x,2];
			ret[3] = buffer[y,x,3];
			
			return ret;
		}
	}
}

